package com.ruoyi.points.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.points.mapper.BargainGroupListMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.points.domain.BargainGroupList;
import com.ruoyi.points.service.IBargainGroupListService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商品统计详情Controller
 *
 * @author ruoyi
 * @date 2024-08-05
 */
@RestController
@RequestMapping("/groupList")
public class BargainGroupListController extends BaseController
{
    @Autowired
    private IBargainGroupListService bargainGroupListService;
@Autowired
    BargainGroupListMapper groupListMapper;

    /**
     * 查询商品统计详情列表
     */
    @RequiresPermissions("points:groupList:list")
    @GetMapping("/list")
    public TableDataInfo list(BargainGroupList bargainGroupList)
    {
        startPage();
        List<BargainGroupList> list = bargainGroupListService.selectBargainGroupListList(bargainGroupList);
        return getDataTable(list);
    }


    @RequiresPermissions("points:groupList:list")
    @GetMapping("/findGroupList")
    public BargainGroupList findGroupList(String bid)
    {
        startPage();
        BargainGroupList bargainGroupList = new BargainGroupList();
        bargainGroupList.setBid(Long.parseLong(bid));
        BargainGroupList list = groupListMapper.findGroupList(bargainGroupList);
        return list;
    }

    /**
     * 导出商品统计详情列表
     */
    @RequiresPermissions("points:groupList:export")
    @Log(title = "商品统计详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BargainGroupList bargainGroupList)
    {
        List<BargainGroupList> list = bargainGroupListService.selectBargainGroupListList(bargainGroupList);
        ExcelUtil<BargainGroupList> util = new ExcelUtil<BargainGroupList>(BargainGroupList.class);
        util.exportExcel(response, list, "商品统计详情数据");
    }

    /**
     * 获取商品统计详情详细信息
     */
    @RequiresPermissions("points:groupList:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bargainGroupListService.selectBargainGroupListById(id));
    }

    /**
     * 新增商品统计详情
     */
    @RequiresPermissions("points:groupList:add")
    @Log(title = "商品统计详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BargainGroupList bargainGroupList)
    {
        return toAjax(bargainGroupListService.insertBargainGroupList(bargainGroupList));
    }

    /**
     * 修改商品统计详情
     */
    @RequiresPermissions("points:groupList:edit")
    @Log(title = "商品统计详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BargainGroupList bargainGroupList)
    {
        return toAjax(bargainGroupListService.updateBargainGroupList(bargainGroupList));
    }

    /**
     * 删除商品统计详情
     */
    @RequiresPermissions("points:groupList:remove")
    @Log(title = "商品统计详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bargainGroupListService.deleteBargainGroupListByIds(ids));
    }
}
